// after several versions , the code looks much better now
#include<stdio.h>
#include<stdlib.h>
int compare_ints(const void *a,const void *b)
{
    int int_a=*(int*)a;
    int int_b=*(int*)b;
    if(int_a<int_b)return -1;
    else if(int_a>int_b)return 1;
    else return 0;
}
int main(){
    int n,q,flag,i;
    scanf("%d%d",&n,&q);
    int* a=malloc(n*sizeof(int));
    if(a==NULL)
    {
        perror("malloc");
        return 1;
    }
    for(i=0;i<n;i++)
    scanf("%d",&a[i]);
    for(i=1;i<=q;i++)
    {
        scanf("%d",&flag);
        int *ans=(int*)bsearch(&flag,a,n,sizeof(int),compare_ints);
        if(ans==NULL)printf("-1\n");
        else printf("%ld\n",ans-a);
    }
    free(a);
    a=NULL;
    return 0;
}


